<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        var a = prompt('请输入你要求的阶乘');
        alert(a + '的阶乘是：' + getJC(a) +'\n' + a + '的阶乘和是：' + getJCSum(a));

        function getJC(num){
            // 求阶乘
            let ans = 1;
            for (let i = 1; i <= num; i++){
                ans *= i;
            }
            return ans;
            
        }

        function getJCSum(num){
            let ans = 0;
            for (let i = 1; i <= num; i++){
                ans += getJC(i);
            }
            return ans;
        }


    </script>
</body>
</html>